<?php
/***************************************************************************
 * @Description: 对象包装
 * 
 * @FileName:         ContentForm.php
 * @Author :          liyong5@staff.sina.com.cn
 * @CreatedTime:      Mon 28 May 2018 05:11:06 PM CST
 ************************************************************************/

namespace app\modules\core\models;

use app\modules\core\Content;
// TODO 引入异常类

class publish extends \yii\base\Compenent
{
    const EVENT_CONTENT_PUBLISH = 'publish';

    const EVENT_CONTENT_DELETE  = 'delete';

    const EVENT_CONTENT_UPDATE  = 'update';

    /**
     * Object [Content Object]
     */
    public $content;

    public function publish() {
        $this->trigger(self::EVENT_CONTENT_PUBLISH, $this->content);
    }

    public function delete() {
        $this->trigger(self::EVENT_CONTENT_DELETE, $this->content);
    }

    public function update() {
        $this->trigger(self::EVENT_CONTENT_UPDATE, $this->content);
    }

    /**
     * @param mix $mix url | id
     */
    public function content($mix) {
    }

    public function form() {
    }

    public function view() {
        if (! $this->content || ! $this->content instanceof Content) {
            // throw a invalid param exception
        }
    }
}
